You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for name, submodule in module.named_modules():
assert submodule not in self.module_set, f"Don't register module={module} twice"
submodule._module_name = name
self.module_set.add(submodule)
module._module_name = module._get_name()
self.module_set.add(module)
The problem with the above line is that the _module_name attribute is attached to the parallel_custom_loss_module and not the nested custom_loss_module.
We would have instead needed to do:
submodule.module._module_name = name
When the call to the forward hook is made, the helper module will internally call:
def forward(self, *inputs, **kwargs):
if not self.device_ids:
return self.module(*inputs, **kwargs)
We should instead simply use: module._get_name() in the forward_hook
Style and formatting:
I have run pre-commit install to ensure that auto-formatting happens with every commit.
Issue number, if available
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
NihalHarish
changed the title
Use get_name in forward hook
Use get_name in forward hook
Oct 30, 2020
NihalHarish
changed the title
Use get_name in forward hook
Use get_name in forward hook
Oct 30, 2020
❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.63%. Comparing base (be862bd) to head (3c9b1ad). ⚠️ Report is 176 commits behind head on master.
❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of bug:
DataParallelCriterionorDataParallelThe problem with the above line is that the
_module_nameattribute is attached to theparallel_custom_loss_moduleand not the nestedcustom_loss_module.We should instead simply use:
module._get_name()in theforward_hookStyle and formatting:
I have run
pre-commit installto ensure that auto-formatting happens with every commit.Issue number, if available
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.